<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>获取元素宽度超过视图的元素</title>
    <style>
        .test {
            width: 2300px;
        }
    </style>
</head>

<body>
    <div class="test"></div>
    请打开控制台查看结果
    <script>
       const getElementsBiggerThanViewport = () => {
            const viewWidth = document.documentElement.offsetWidth;
            return [...document.querySelectorAll('*')].filter(el => el.offsetWidth > viewWidth);
       }
       const elements = getElementsBiggerThanViewport();
       console.log(elements)
    </script>
</body>

</html>